#include "ServerRenting.h"
#include <iostream>

using namespace std;

void main()
{
	int tieptuc(0);
	ResultInfo* server;
	ResultInfo* superserver;
	do
	{
		system("cls");
		string username;
		string password;
		string leasetime;
		int difficulty;
		cout<< "Nhap thong tin nguoi dung." << endl << endl;

		cout<< "Ten: ";
		cin >> username;
		cout<< endl;

		cout << "Mat khau: ";
		cin >> password;
		cout << endl;

		cout << "Thoi diem thue: ";
		cin >> leasetime;
		cout << endl;

		cout << "Do phuc tap: "; 
		cin >> difficulty;
		cout << endl;

		cout<<"Chon loai server muon thue:"<<endl;
		cout<< "1. Server."<<endl;
		cout<< "2. Supper Server."<<endl;
		cout<< "3. Huy thao tac."<<endl;
		cout<< "Toi chon (1 | 2 | 3): " ;
		
		int select(0);

		cin >> select;
		cout<< endl;

		User* a = new User(username,password,leasetime,difficulty);
	
		switch (select)
		{

			case 1:
		
				server = ServerRenting::rentServer(a);
				if(server == NULL)
				{
					cout << "Khong thue duoc server naovi tat ca dang ban ." <<endl; 
				}
				else
				{
					cout << "Da thue duoc server voi thong tin sau: "<<endl;
					server->showInfo();
					delete server;
				}
				break;

			case 2:

				superserver = ServerRenting::rentSuperServer(a);

				if(superserver == NULL)
				{
					cout << "Khong thue duoc super server nao vi tat ca dang ban." <<endl; 
				}
				else
				{
					cout << "Da thue duoc super server voi thong tin sau: "<<endl;
					superserver->showInfo();
					delete superserver;
				}
				break;
			default: 
				break;
		}


		cout << endl;
		cout << "Co muon tiep tuc thue server ?" << endl; 
		cout << "1. Co\t\t 2.Khong" <<  endl;
		cout << "Toi chon (1 | 2): ";
		cin >> tieptuc;
		cout << endl;
	}
	while(tieptuc == 1);

	ServerRenting::destroyServers();

}

